﻿<UserControl
    x:Class="DvachBrowser3.Views.Partial.ContentPopup"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:DvachBrowser3.Views.Partial"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">
    
    <UserControl.Resources>
        <Storyboard x:Key="ShowContentAnimation">
            <DoubleAnimation Storyboard.TargetName="BodyContainer" Storyboard.TargetProperty="Opacity" Duration="0:0:0.12" From="0.25" To="1.0" />
            <DoubleAnimation Storyboard.TargetName="BodyScale" Storyboard.TargetProperty="Y" Duration="0:0:0.12" From="16.0" To="0.0">
                <DoubleAnimation.EasingFunction>
                    <ExponentialEase EasingMode="EaseIn" />
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainView" Storyboard.TargetProperty="Visibility">
                <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="Visible" />
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainView" Storyboard.TargetProperty="Background">
                <DiscreteObjectKeyFrame KeyTime="0:0:0.0">
                    <DiscreteObjectKeyFrame.Value>
                        <SolidColorBrush Color="Black" Opacity="0.5" />
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="HideContentAnimation">
            <DoubleAnimation Storyboard.TargetName="BodyContainer" Storyboard.TargetProperty="Opacity" Duration="0:0:0.12" From="1.0" To="0.0" />
            <DoubleAnimation Storyboard.TargetName="BodyScale" Storyboard.TargetProperty="Y" Duration="0:0:0.12" From="0.0" To="16.0">
                <DoubleAnimation.EasingFunction>
                    <ExponentialEase EasingMode="EaseOut" />
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainView" Storyboard.TargetProperty="Visibility">
                <DiscreteObjectKeyFrame KeyTime="0:0:0.12" Value="Collapsed" />
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainView" Storyboard.TargetProperty="Background">
                <DiscreteObjectKeyFrame KeyTime="0:0:0.0">
                    <DiscreteObjectKeyFrame.Value>
                        <SolidColorBrush Color="Transparent" />
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <Border x:Name="MainView" Visibility="Collapsed">
        <Border.Background>
            <SolidColorBrush Color="Black" Opacity="0.5" />
        </Border.Background>
        <Grid x:Name="BodyContainer">
            <Grid.RenderTransform>
                <TranslateTransform x:Name="BodyScale" X="0" Y="0" />
            </Grid.RenderTransform>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="100*" />
            </Grid.RowDefinitions>
            <Button Grid.Row="0" Margin="0, 5, 0, 5" HorizontalAlignment="Right" Visibility="{x:Bind IsShowCloseButton, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=false}"
                    Background="Transparent" MinWidth="48" ToolTipService.ToolTip="Закрыть" Click="CloseButton_OnClick">
                <Viewbox Height="16" Width="16">
                    <SymbolIcon Symbol="Clear" Foreground="White" />
                </Viewbox>
            </Button>
            <Border Grid.Row="1" BorderThickness="1, 1, 1, 1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="Body" Padding="4">
                <Border.BorderBrush>
                    <SolidColorBrush Color="{ThemeResource SystemColorWindowTextColor}" Opacity="0.66" />
                </Border.BorderBrush>
                <ContentPresenter Content="{x:Bind ViewContent}" ContentTemplate="{x:Bind ViewContentTemplate, Mode=OneWay}" ContentTemplateSelector="{x:Bind ViewContentTemplateSelector, Mode=OneWay}"/>
            </Border>
        </Grid>
    </Border>
</UserControl>
